#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Project ：t-player
@File    ：t-player.py
@Author  ：kehao
@Date    ：2021/8/1 22:10
"""
import collections
import json
import logging.config
import os

os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = '1'

import sys

import yaml

from EventHandle import EventHandle
from Player import Player

if sys.version_info > (3, 9):
    collections.Iterable = collections.abc.Iterable

if os.path.exists('logging.yml'):
    with open('logging.yml', mode='rt', encoding='utf8') as f:
        logging.config.dictConfig(yaml.safe_load(f.read()))
else:
    logging.basicConfig(level=logging.INFO)

logger = logging.getLogger()

if __name__ == '__main__':
    with open('./data.json', mode='rt', encoding='utf8') as f:
        data = json.load(f)
    player = Player(data)
    thread = EventHandle(1, "EventHandle-Thread", player)
    thread.daemon = True
    thread.start()
    player.play()
